function OS_TalkDialog(game,scene,winres,params)
{
	this.$super=OS_Dialog;
	this.$super(game,scene,winres,params);
	delete this.$super;
	
	var charDelay=50;
	var textTime=null;
	var lines=null;
	var wordPointer=0;
	var linePointer=0;
	var waitConfirm=false;
	
	var instance=this;
	
	var initLines=function()
	{
		lines=[];
		var text=params.words[wordPointer];
		var start=0;
		var stop=1;
		while (stop<=text.length)
		{
			var str_temp=text.substring(start,stop);
			var text_drawing={
						content:str_temp,
						bold:true,
						size:20
					};
			var c_width=game.stage.measureText(text_drawing).width;
			if (c_width<=instance.contentWidth)
			{
				stop++;
			}
			else
			{
				var str_temp=text.substring(start,stop-1);
				lines.push(str_temp);
				start=stop-1;
			}
		}
		var str_temp=text.substring(start,stop-1);
		lines.push(str_temp);
	}
	
	this.updateContent=function()
	{
		var nowTime=(new Date()).getTime();
		if (textTime==null) textTime=nowTime;
		if (lines==null) initLines();
		var charCount=Math.ceil((nowTime-textTime)/charDelay);
		var charTotal=0;
		if (!!params.talkerPortrait)
		{
			params.talkerPortrait.type="portrait";
			this.drawList.push(params.talkerPortrait);
		}
		for (var i=linePointer;i<linePointer+3&&i<lines.length;i++)
		{
			charTotal+=lines[i].length;
		}
		if (charCount>charTotal) waitConfirm=true;
		for (var i=linePointer;i<linePointer+3&&i<lines.length;i++)
		{
			if (charCount<=lines[i].length)
			{
				var drawing={
						type:"text",
						line:i-linePointer,
						text:lines[i],
						textLen:charCount,
						background:null
					};
				this.drawList.push(drawing);
				break;
			}
			else
			{
				var drawing={
						type:"text",
						line:i-linePointer,
						text:lines[i],
						textLen:lines[i].length,
						background:null
					};
				this.drawList.push(drawing);
				charCount-=lines[i].length;
			}
		}
		if (linePointer==0&&!!params.talker)
		{
			var drawing={
					type:"name",
					text:params.talker,
					color:params.talkerColor
				};
			this.drawList.push(drawing);
		}
		if (waitConfirm)
		{
			this.confirmFlag=Math.floor(nowTime%500/67.5)+1;
		}
		else
		{
			this.confirmFlag=0;
		}
		if (this.getActiveKey()=="enter")
		{
			if (waitConfirm)
			{
				waitConfirm=false;
				if (linePointer+3<lines.length)
				{
					linePointer+=3;
					textTime=nowTime;
				}
				else
				{
					wordPointer++;
					lines=null;
					linePointer=0;
					if (wordPointer>=params.words.length)
					{
						this.close();
					}
					else
					{
						textTime=nowTime;
					}
				}
			}
			else
			{
				textTime=0;
			}
		}
	}
}
